
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    timeCountDownTop:"获取验证码",
    second:60,
    counting: false
  },

  /**
   * 组件的方法列表
   */
  methods: {
    getVerifityCode: function() {
      var that = this;
      if (!that.data.counting) {
        wx.showToast({
          title: '验证码已发送',
        })
        //开始倒计时
        countDown(that, that.data.second);
      }
  
      function countDown(that, count) {
        if (count == 0) {
          that.setData({
            timeCountDownTop: '获取验证码',
            counting: false
          })
          return;
        }
  
        that.setData({
          counting: true,
          timeCountDownTop: count + '秒后重新获取',
          second: count
        })
        setTimeout(function() {
          count--;
          countDown(that, count);
        }, 1000);
      }
    },
  }
})